<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript" src="/thirdparty/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#order_grid").ligerGrid({
				//checkbox: true,
				title : '门票订单列表',
                columns: [
				{ display: "订单号", name: 'id',width:100},
                { display: "取票人", name: 'contactor',width:80},
                { display: "订票详情", name: 'orderDetail',width:400},
                { display: '票号', name: 'stampNum',width:80},
                { display: "游玩日期", name: 'orderTime',width:80},
                { display: "签名",width:100,height:50}
                ], 
                pageSize:20,
                root :'list',
                record:'totalRecord',
                url: "/misc/order/companyordergrid.htm?type=01", 
                width: '99%',height:'99%',
                groupColumnName:"pname",
                groupRender:function(pname,groupdata){
                	return pname;
                },
                onAfterShowData:function(){
                	$(".l-grid-row-cell-inner").css("height","auto");
                }
            });

	});
	
	
	function downLoadExcel(){
		var companyName=$("#companyName").val();
		var url="/misc/order/exportexcel.htm?orderType=01";
		var beginDate=$("#beginDate").val();
		if(companyName!="" && companyName!=null){
			var company=$("#company").val();
			
			var ticket=$("#company_ticket").text();
			if(ticket!=null && ticket!=""){
				url+="&ticket="+ticket;
			}
		}
		if(beginDate!=""){
			url+="&beginDate="+beginDate;
		}
		var endDate=$("#endDate").val();
		if(endDate!=""){
			url+="&endDate="+endDate;
		}
		window.location.href=url;
	}
	
	function searchTicket(){
		  var companyName=$("#companyName").val();
		  if(companyName!=null && companyName !=""){
			  $("#company_ticket").empty();
			  var company=$("#company").val();
			  $.get("/misc/order/companyticket.htm?company="+company,function(data){
				  $("#search_ticket").show();
				  $.each(data,function(i){
					 $("#company_ticket").append("<option value='" + data[i].id + "'>" + data[i].name+ "</option>");
				  });
			  },'json');
			  
		  }else{
			  $("#search_ticket").hide();
		  }
	}
	
	function search(){
		var companyName=$("#companyName").val();
		var company="";
		var ticket="";
		if(companyName!="" && companyName!=null){
			company=$("#company").val();
			ticket=$("#company_ticket").text();
		}else{
			$("#search_ticket").hide();
		}
		grid_ae.options.parms = [{name:'beginDate',value:$("#beginDate").val()},{name:'endDate',value:$("#endDate").val()},{name:'company',value:company},{name:'ticket',value:ticket}];
		grid_ae.loadData();
	}
</script>
<div id="searchbar">
	<table>
		<tr style="font-size: 12px">
			<td>查看游玩日期范围：从<input name="date" id="beginDate" type="text" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,highLineWeekDay:true,isShowOthers:true})"/></td>
			<td>到<input name="date" id="endDate" type="text"  class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,highLineWeekDay:true,isShowOthers:true})"/></td>
			<sec:authorize ifNotGranted="ROLE_COMPANY" >
			<td>公司:</td>
			<td><%@include file="../company/companyName.jsp"%></td>
			<td><input type="button" value="查询公司门票:" onclick="searchTicket()"></td>
			<td id="search_ticket" style="display: none;"><select id="company_ticket"></select></td>
			</sec:authorize>
			<td><input id="btnOK" type="button" value="查询订单" onclick="search()" /></td>
	    	<td><a href="javascript:void(0)" id="dl_a" onclick="downLoadExcel();">下载excel</a></td>
		</tr>
	</table>
</div>
<div id="order_grid" style="margin:0; padding:0"></div>
